package ui.panel.setup.subsidiary;

import javafx.scene.Group;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Paint;
import javafx.scene.shape.SVGPath;
import javafx.scene.text.Font;
import ui.factory.SingletonFactory;

import java.io.IOException;

public class SetUpFavoriteTypeMenu {
    private static SetUpFavoriteTypeMenu instance;
    //调用单例工厂
    public static SetUpFavoriteTypeMenu getInstance() {
        if (instance == null) {
            instance = SingletonFactory.getWeakInstace(SetUpFavoriteTypeMenu.class);
        }
        return instance;
    }
    public Pane favoriteTypeOfSystemRandom() {
        Pane pane = newFavoriteButton("系统随机");
        ImageView comicsAndAnimation = new ImageView(new Image("/fxml/css/images/menu/Star.png"));
        comicsAndAnimation.setLayoutX(60);
        comicsAndAnimation.setLayoutY(120);
        pane.getChildren().add(comicsAndAnimation);

        return pane;
    }

    public Pane favoriteTypeOfSexy() {
        Pane pane = newFavoriteButton("性感写真");
        ImageView comicsAndAnimation = new ImageView(new Image("/fxml/css/images/menu/Star.png"));
        comicsAndAnimation.setLayoutX(60);
        comicsAndAnimation.setLayoutY(120);
        pane.getChildren().add(comicsAndAnimation);

        return pane;
    }
    public Pane favoriteTypeOfStar() {
        Pane pane = newFavoriteButton("    明    星");
        ImageView comicsAndAnimation = new ImageView(new Image("/fxml/css/images/menu/Star.png"));
        comicsAndAnimation.setLayoutX(60);
        comicsAndAnimation.setLayoutY(120);
        pane.getChildren().add(comicsAndAnimation);

        return pane;
    }
    public Pane favoriteTypeOfPets() {
        Pane pane = newFavoriteButton("   宠  物");
        ImageView comicsAndAnimation = new ImageView(new Image("/fxml/css/images/menu/Pets.png"));
        comicsAndAnimation.setLayoutX(60);
        comicsAndAnimation.setLayoutY(120);
        pane.getChildren().add(comicsAndAnimation);

        return pane;
    }
    public Pane favoriteTypeOfPhotography() {
        Pane pane = newFavoriteButton("现代风摄影");
        ImageView comicsAndAnimation = new ImageView(new Image("/fxml/css/images/menu/Photography.png"));
        comicsAndAnimation.setLayoutX(60);
        comicsAndAnimation.setLayoutY(120);
        pane.getChildren().add(comicsAndAnimation);

        return pane;
    }
    public Pane favoriteTypeOfComicsAndAnimation() {
        Pane pane = newFavoriteButton("   动   漫");
        ImageView comicsAndAnimation = new ImageView(new Image("/fxml/css/images/menu/ComicsAndAnimation.png"));
        comicsAndAnimation.setLayoutX(70);
        comicsAndAnimation.setLayoutY(120);
        pane.getChildren().add(comicsAndAnimation);

        return pane;
    }
    public Pane favoriteTypeOfBeauty() {
        Pane pane = newFavoriteButton("   美   女");
        ImageView comicsAndAnimation = new ImageView(new Image("/fxml/css/images/menu/Beauty.png"));
        comicsAndAnimation.setLayoutX(70);
        comicsAndAnimation.setLayoutY(120);
        pane.getChildren().add(comicsAndAnimation);

        return pane;
    }
    public Pane favoriteTypeOfScenery() {
        Pane pane = newFavoriteButton("   风   景");
        ImageView comicsAndAnimation = new ImageView(new Image("/fxml/css/images/menu/Scenery.png"));
        comicsAndAnimation.setLayoutX(70);
        comicsAndAnimation.setLayoutY(120);
        pane.getChildren().add(comicsAndAnimation);

        return pane;
    }

    /**
     * 每日精选菜单
     */
    public Pane favoriteTypeOfDailySelectionMenu() {
        Pane pane = newFavoriteButton("每日精选");
        Group group = new Group();
        SVGPath svg = new SVGPath();
        svg.setContent("M510.78418813 93.60675875c99.157215 0 198.27379031 0.57234562 297.43015968-0.40893937 26.9866125-0.24468656 45.5505975 9.69093188 59.86178157 31.893885 33.65156156 51.97001438 68.12184938 103.36852875 102.34575656 155.01172968 19.30058344 29.11343531 19.83144281 54.95535562-1.26661125 82.88261344-80.3883375 106.76281031-161.34986719 213.03455437-242.02437656 319.51034531-52.37980031 69.26738719-105.04407937 138.16562906-156.85153407 207.80046938-40.03118531 53.80981781-76.50383625 53.93258437-116.53502156 0.85767187-132.85026375-175.82445844-266.18989969-351.28061625-399.44910281-526.90102875-18.27696562-24.08424281-20.48506875-54.0561975-4.57961344-78.46725281 35.69625844-54.91386937 72.16975688-109.29687938 107.70260906-164.2530825 12.71691375-19.58590969 29.03215594-28.49960344 53.23747219-28.33619719 100.01658094 0.90000563 200.11359469 0.40978594 300.12848063 0.40978594z m31.24025906 724.67274656c-0.40809281 2.54507625-3.23002875 8.39299406 3.19023562 11.50025625 5.52025781 2.65852969 10.67137031-0.49106625 14.47459125-4.13003437 3.80237437-3.68045438 6.42026344-8.46411375 9.64944469-12.67542656 75.31850531-99.37226812 150.71913656-198.88677656 226.11807469-298.3699575 38.47670813-50.78552906 77.15830875-101.48808469 115.26756375-152.51830032 13.00224-17.41844719 9.36411937-24.53382281-12.55266094-25.88256093-12.43074094-0.73659844-24.94276219-0.28617281-37.49542219-0.49106625-8.70964688-0.08212688-17.01035437-2.57555625-17.86887281-12.18520782-0.98043844-11.04051656 7.40070188-15.49736344 17.09248031-16.06970906 13.3299-0.90000563 26.82405281-0.3268125 40.15395188-0.981285 18.76803094-0.85851844 24.57361594-9.32263219 13.94373281-25.63787437-26.98745906-41.50269-54.17896406-82.96389281-81.57451594-124.13977032-8.17794094-12.34861406-19.54611656-13.77947906-28.41832312-1.75852312-31.48579219 42.72950813-61.98860531 86.11264219-92.81907844 129.37385531-5.92919719 8.34219375-8.13645469 16.27460156 3.63981469 21.38592094 9.28114594 4.00642031 24.08254969 4.41620625 19.78995656 19.29973687-4.08939375 14.38230469-18.85015781 11.40796969-29.80770094 10.71285657-20.32335563-1.14553781-30.7898325 6.46005656-35.77838531 26.70043968-8.05602094 33.93773437-19.05505125 67.34461031-28.66385625 101.07829875-20.15910281 70.94293875-40.44012469 141.72331687-60.18944156 212.58497532-12.92350031 46.5318825-25.06722188 93.26950406-38.15158875 142.20337593z m-29.27684156-482.28091687c-36.63690375 0-73.27380844 0.20489344-109.91071219-0.08127938-17.86887281-0.20404594-27.10937812 4.70237906-21.42571407 25.06468125 17.17291406 60.76178719 33.07921594 121.80974719 49.92616407 182.73578813a23199.30432375 23199.30432375 0 0 0 58.88049656 210.33453844c4.57961344 16.23396187 4.66173937 43.17993375 21.75252656 42.89376093 17.29652719-0.16340625 16.151835-27.8459775 20.73144844-43.54823343 24.53382281-84.19071094 47.59529437-168.83184844 71.10549844-253.26894 12.26733469-43.91484 25.76064094-87.5849925 36.55562344-131.78600532 7.27878187-29.76706125 4.29343969-32.01580406-25.92404625-32.22154406-33.85560844-0.40893937-67.79418938-0.20404594-101.691285-0.12276656z m-285.53112376 0c-31.28005219-0.08128031-62.51946469-0.28532625-93.79951687 0.12276656-9.40475906 0.08212688-20.976135-3.23002875-26.74192594 7.19665594-6.01132406 11.12179594 4.98855281 17.74610625 10.38604407 24.94191562C229.62863094 517.22138562 342.48404563 665.93477187 455.29797312 814.69049094c4.57961344 6.05111719 8.09581406 16.601415 17.9095125 11.32584281 10.95838969-5.84622469 6.50154375-16.84525406 3.76173469-26.12724656-16.51928813-57.24558562-33.44751562-114.36755906-49.68063094-171.77570438-25.4338275-90.24352219-50.7846825-180.60981094-75.31765781-271.17929906-4.33492688-16.19247563-13.28925938-21.22166719-28.54108969-21.09890156-31.893885 0.36829969-64.03330219 0.16340625-96.21336 0.16340625z m105.24981938-200.27615344v-0.12276656c-33.03857625 0-66.0771525 0.7763925-99.11572875-0.24553313-19.91272313-0.57234562-33.77517469 6.29749687-44.44654594 23.02083188-26.61915937 41.7075825-54.13747688 82.88261344-81.53302875 124.13977031-10.18199813 15.21118969-6.21537094 23.67530344 11.73478219 23.83870969 59.82114188 0.49106625 119.64228375 0.49106625 179.5455525 0.12276656 20.56719563-0.20489344 22.6118925-10.05923156 11.2445625-25.228935-14.72012437-19.87208344-29.44024875-39.90841875-43.62951281-60.14880094-5.92835063-8.34134719-15.16970344-18.15504562-1.6357575-27.06873843 12.02180156-7.85112844 18.11440594 3.76088719 23.30700468 10.83562312 17.41929375 23.51105062 34.22475469 47.30827406 50.3351025 71.63805094 11.32668937 17.13227344 21.79401375 16.15098844 32.95729688 0.81703219 27.72321094-37.82223563 55.813875-75.44127187 82.71920625-113.75372625 13.3299-19.01441063 9.03645937-26.98745906-14.39331094-27.55980469-35.65646531-0.97959188-71.43485063-0.28447969-107.08962281-0.28447969z m177.37808906 170.83590563c32.05729125 0 64.23734812 0.12276656 96.29463938-0.08128032 7.03240219 0 14.96481094 1.06341188 19.46229656-5.8885575 5.683665-8.79092625-1.59427125-14.80225031-6.05111719-21.05826093-31.07515875-43.01568094-62.64223125-85.58178281-93.51334406-128.76087-9.89582531-13.82011875-17.54206031-15.50752312-28.05087-0.85851844-31.52558531 43.75143281-63.7869225 87.01264688-94.98569531 130.92748594-12.71606719 17.99163938-8.99581969 24.94276219 13.12585312 25.51510781 31.32069188 0.77723906 62.51946469 0.20489344 93.7182375 0.20489344z m262.59157219-155.59423594c-0.28617281-16.42700156-11.69498906-15.24082313-20.97698156-15.24082313-56.30409375-0.28617281-112.48626844-0.20489344-168.7497225-0.12276656-7.76984813 0-17.50141969-1.92193031-21.54932719 6.86899594-4.00642031 8.38198687 3.68130094 14.80225031 8.01453469 21.09890156 26.08745344 36.80031 52.6253325 73.27296094 78.67214625 110.07411844 13.69735219 19.42250344 21.26146125 20.15825625 35.57349281 1.10405156 26.49554625-35.41008563 52.46107969-71.18847094 78.50789344-107.00749687 4.16982656-5.64302437 7.48198219-11.85839531 10.50796406-16.77498094z");
        svg.setFill(Paint.valueOf("#1afa29"));
        svg.setScaleX(0.07);
        svg.setScaleY(0.07);
        svg.setLayoutX(-420);
        svg.setLayoutY(-350);
        group.getChildren().add(svg);

        Label label = new Label("每日精选");
        label.setLayoutX(130);
        label.setLayoutY(130);
//        label.setTextFill(Paint.valueOf("#1afa29"));
        try {
            label.setFont(Font.loadFont(this.getClass().getResource("/fxml/font/xinkai.ttf").openStream(), 40));
        } catch (IOException e) {
            label.setMinSize(18, 18);
        }
        pane.getChildren().addAll(group, label);

        return pane;
    }


    private Pane newFavoriteButton(String menuName) {
        Pane pane = new Pane();
//        pane.setStyle("-fx-background-color:#ec2c64;");
        pane.setLayoutX(125);
        pane.setLayoutY(100);
        pane.setPrefHeight(356);
        pane.setPrefWidth(356);

        Label label = new Label(menuName);
        label.setLayoutX(130);
        label.setLayoutY(130);
//        label.setTextFill(Paint.valueOf("#1afa29"));
        try {
            label.setFont(Font.loadFont(this.getClass().getResource("/fxml/font/xinkai.ttf").openStream(), 40));
        } catch (IOException e) {
            label.setMinSize(18, 18);
        }
        Button button = new Button();
        button.setStyle("-fx-shape: 'M578.141384 1020.928a122.796277 122.796277 0 0 1-87.54234-36.297258L102.15527 596.186969c-135.625258-135.625258-135.625258-356.326239 0-491.951497C232.589686-26.192503 441.691774-31.203019 578.205786 89.223245c136.44961-120.419824 345.558138-115.480151 475.986113 15.012227 135.631698 135.631698 135.631698 356.326239 0 491.951497l-388.437333 388.443773a123.053887 123.053887 0 0 1-87.613182 36.297258zM348.134239 78.519547c-69.619119 0-139.238239 26.475874-192.26083 79.498466-105.98078 105.98078-105.98078 278.476478 0 384.450817l388.443773 388.443774a47.432453 47.432453 0 0 0 33.824202 14.001107 47.690063 47.690063 0 0 0 33.830641-14.001107l388.443774-388.443774c105.97434-105.98078 105.97434-278.476478 0-384.450817-105.98078-105.98078-278.476478-105.98078-384.457258 0l-10.890466 10.961308a37.926642 37.926642 0 0 1-53.718138 0l-10.961308-10.961308c-53.022591-53.022591-122.699673-79.498465-192.25439-79.498466z M968.742642 444.91834a36.709434 36.709434 0 0 1-9.692579-1.26873 37.997484 37.997484 0 0 1-27.113459-46.434214c12.603572-47.825308-1.333132-99.263597-36.232856-134.234163a139.792101 139.792101 0 0 0-107.629484-40.541384 37.913761 37.913761 0 0 1-40.348176-35.472906 37.958843 37.958843 0 0 1 35.472906-40.348176 215.387774 215.387774 0 0 1 166.287295 62.644327c53.969308 53.969308 75.441107 133.409811 55.991547 207.273057a38.023245 38.023245 0 0 1-36.735194 28.382189z';-fx-effect: dropshadow(three-pass-box,rgba(223,204,211,0.66),10,0,0,0);-fx-background-color:#ec2c64;");
        button.setPrefHeight(43);
        button.setPrefWidth(47);
        button.setLayoutX(75);
        button.setLayoutY(245);

        Button button1 = new Button();
        button1.setStyle("-fx-shape: 'M958.805 571.276h2v1h-2zM485.36 897.546c-7.702 0-14.937-3.021-20.368-8.476L158.935 583.06c-51.669-46.379-81.542-113.171-81.542-182.82 0-39.144 9.412-78.124 27.204-112.68l21.305 10.957c-16.271 31.652-24.536 65.856-24.536 101.723 0 62.859 26.994 123.145 74.051 165.425l306.549 306.479a4.764 4.764 0 0 0 3.395 1.429 4.81 4.81 0 0 0 3.418-1.429l116.073-116.026 16.95 16.949-116.074 116.027c-5.431 5.455-12.665 8.452-20.368 8.452zM740.919 653.926l-16.949-16.95 67.729-67.729c46.098-42.983 71.335-100.739 71.335-162.943 0-122.723-99.85-222.549-222.549-222.549-54.034 0-106.241 19.83-147.023 55.813l-8.241 7.257-7.96-7.562c-41.672-39.682-96.127-61.549-153.345-61.549-22.826 0-45.301 3.442-66.816 10.208l-7.211-22.85c23.856-7.515 48.743-11.331 74.027-11.331 59.816 0 116.893 21.539 161.913 60.893 43.873-35.445 98.375-54.853 154.656-54.853 135.927 0 246.522 110.596 246.522 246.523 0 68.923-27.953 132.907-78.662 180.198l-67.426 67.424z M806.331 432.336h-23.974c0-62.79-17.652-108.091-52.465-134.64-61.83-47.104-158.426-21.351-159.409-21.094l-6.32-23.13c4.401-1.217 109.097-29.124 180.268 25.167 41.064 31.325 61.9 83.042 61.9 153.697zM782.357 463.474h23.974v20.181h-23.974z M713.06 769.719l-92.382-150.115H411.615V399.865H283.741V261.807L141.587 173.71l12.619-20.368 153.508 95.12v127.429h127.873v219.74h198.482l99.406 161.539z';-fx-effect: dropshadow(three-pass-box,rgba(0,0,0,0.66),10,0,0,0);-fx-background-color:ee4866;");
        button1.setPrefHeight(40);
        button1.setPrefWidth(45);
        button1.setLayoutX(235);
        button1.setLayoutY(247);

        pane.getChildren().addAll(label, button, button1);

        return pane;
    }
}
